#ifndef ROLE_MGR_H
#define ROLE_MGR_H

#include "SimpleActor.h"
#include <singleton.h>
#include "RoleMgrEvents.h"
#include <tbb/concurrent_hash_map.h>
#include "ActorTypeFwd.h"

class CRoleMgrActor : public CSimpleActor, public CSingleton<CRoleMgrActor>
{
    friend class CSingleton<CRoleMgrActor>;
    typedef tbb::concurrent_hash_map<string, TRoleActor> TRoleList;
public:
    // explicit constructor
    CRoleMgrActor(CSimpleActor * pParent = NULL);

    // default destructor
    ~CRoleMgrActor(void);

    // get the class name
    virtual const char * GetTypeName() const { return "CRoleMgrActor"; }

    bool FindRole(const char * szName, TRoleActor & pRoleActor) const;

	bool FindRole(uint32 nID, TRoleActor & pRoleActor) const;

	bool CreateRole(const char * szName, TRoleActor & pRoleActor);

	void ReleaseRole(const char * szName);

protected:
    //user-defined behavior implementation hooks
    virtual bool _Receive(TEvent event);

    bool _Init();

    void _GetRoleData(IRoleMgrEvent *);
protected:
    TRoleList m_roleList;
    CRoleMgr m_oRoleMgr;

};

#endif // endif of ROLE_MGR_H
